package org.HU.train.common.exception;

/**
 * @Author ZUZ
 * @Description: 自定义业务异常
 * @Date 2024-12-17 21:03
 * @ClassName: BusinessException
 */
public class BusinessException extends RuntimeException{

    private BusinessExceptionEnum businessExceptionEnum;

    public BusinessException(BusinessExceptionEnum businessExceptionEnum) {
        this.businessExceptionEnum = businessExceptionEnum;
    }

    public BusinessExceptionEnum getBusinessExceptionEnum() {
        return businessExceptionEnum;
    }

    public void setBusinessExceptionEnum(BusinessExceptionEnum businessExceptionEnum) {
        this.businessExceptionEnum = businessExceptionEnum;
    }

    /**
     *不写入堆栈信息，提高性能
     *发生业务异常时，我们已经知道是什么导致异常，因此不需要再打印完整的堆栈异常信息
     */
    @Override
    public synchronized Throwable fillInStackTrace() {
        //不需要递归调用这个函数然后一层层打印异常信息，只需要打印当前异常类即可
        return this;
    }
}
